<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=2">
<meta name="theme-color" content="#222">
<meta name="generator" content="Hexo 5.4.0">
  <link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon-next.png">
  <link rel="icon" type="image/png" sizes="32x32" href="/images/favicon-32x32-next.png">
  <link rel="icon" type="image/png" sizes="16x16" href="/images/favicon-16x16-next.png">
  <link rel="mask-icon" href="/images/logo.svg" color="#222">

<link rel="stylesheet" href="/css/main.css">


<link rel="stylesheet" href="/lib/font-awesome/css/all.min.css">

<script id="hexo-configurations">
    var NexT = window.NexT || {};
    var CONFIG = {"hostname":"vchao.top","root":"/","scheme":"Muse","version":"7.8.0","exturl":false,"sidebar":{"position":"left","display":"post","padding":18,"offset":12,"onmobile":false},"copycode":{"enable":false,"show_result":false,"style":null},"back2top":{"enable":true,"sidebar":false,"scrollpercent":false},"bookmark":{"enable":false,"color":"#222","save":"auto"},"fancybox":false,"mediumzoom":false,"lazyload":false,"pangu":false,"comments":{"style":"tabs","active":null,"storage":true,"lazyload":false,"nav":null},"algolia":{"hits":{"per_page":10},"labels":{"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}},"localsearch":{"enable":false,"trigger":"auto","top_n_per_article":1,"unescape":false,"preload":false},"motion":{"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}}};
  </script>

  <meta name="description" content="&gt;今天需要写一个跳转到系统拨号页面的功能，其实简单的很，就一句话的事儿。不过念在系统页面众多，于是乎，在此做一个总结，万一以后忘记了，也方便查阅。 系统页面跳转浏览器浏览网页123Uri uri &#x3D; Uri.parse(&quot;http:&#x2F;&#x2F;www.google.com&quot;);   Intent intent   &#x3D; new Intent(Intent.ACTION_VIEW,">
<meta property="og:type" content="article">
<meta property="og:title" content="安卓备忘：跳转系统页面以及常见APP相应页面">
<meta property="og:url" content="http://vchao.top/2017/05/12/%E5%AE%89%E5%8D%93%E5%A4%87%E5%BF%98%EF%BC%9A%E8%B7%B3%E8%BD%AC%E7%B3%BB%E7%BB%9F%E9%A1%B5%E9%9D%A2%E4%BB%A5%E5%8F%8A%E5%B8%B8%E8%A7%81APP%E7%9B%B8%E5%BA%94%E9%A1%B5%E9%9D%A2/index.html">
<meta property="og:site_name" content="乘风破浪">
<meta property="og:description" content="&gt;今天需要写一个跳转到系统拨号页面的功能，其实简单的很，就一句话的事儿。不过念在系统页面众多，于是乎，在此做一个总结，万一以后忘记了，也方便查阅。 系统页面跳转浏览器浏览网页123Uri uri &#x3D; Uri.parse(&quot;http:&#x2F;&#x2F;www.google.com&quot;);   Intent intent   &#x3D; new Intent(Intent.ACTION_VIEW,">
<meta property="og:locale" content="zh_CN">
<meta property="article:published_time" content="2017-05-12T12:03:39.000Z">
<meta property="article:modified_time" content="2021-08-25T14:37:20.801Z">
<meta property="article:author" content="vchao">
<meta property="article:tag" content="Android">
<meta property="article:tag" content="Android Studio">
<meta name="twitter:card" content="summary">

<link rel="canonical" href="http://vchao.top/2017/05/12/%E5%AE%89%E5%8D%93%E5%A4%87%E5%BF%98%EF%BC%9A%E8%B7%B3%E8%BD%AC%E7%B3%BB%E7%BB%9F%E9%A1%B5%E9%9D%A2%E4%BB%A5%E5%8F%8A%E5%B8%B8%E8%A7%81APP%E7%9B%B8%E5%BA%94%E9%A1%B5%E9%9D%A2/">


<script id="page-configurations">
  // https://hexo.io/docs/variables.html
  CONFIG.page = {
    sidebar: "",
    isHome : false,
    isPost : true,
    lang   : 'zh-CN'
  };
</script>

  <title>安卓备忘：跳转系统页面以及常见APP相应页面 | 乘风破浪</title>
  






  <noscript>
  <style>
  .use-motion .brand,
  .use-motion .menu-item,
  .sidebar-inner,
  .use-motion .post-block,
  .use-motion .pagination,
  .use-motion .comments,
  .use-motion .post-header,
  .use-motion .post-body,
  .use-motion .collection-header { opacity: initial; }

  .use-motion .site-title,
  .use-motion .site-subtitle {
    opacity: initial;
    top: initial;
  }

  .use-motion .logo-line-before i { left: initial; }
  .use-motion .logo-line-after i { right: initial; }
  </style>
</noscript>

</head>

<body itemscope itemtype="http://schema.org/WebPage">
  <div class="container use-motion">
    <div class="headband"></div>

    <header class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-container">
  <div class="site-nav-toggle">
    <div class="toggle" aria-label="切换导航栏">
      <span class="toggle-line toggle-line-first"></span>
      <span class="toggle-line toggle-line-middle"></span>
      <span class="toggle-line toggle-line-last"></span>
    </div>
  </div>

  <div class="site-meta">

    <a href="/" class="brand" rel="start">
      <span class="logo-line-before"><i></i></span>
      <h1 class="site-title">乘风破浪</h1>
      <span class="logo-line-after"><i></i></span>
    </a>
  </div>

  <div class="site-nav-right">
    <div class="toggle popup-trigger">
    </div>
  </div>
</div>




<nav class="site-nav">
  <ul id="menu" class="main-menu menu">
        <li class="menu-item menu-item-home">

    <a href="/" rel="section"><i class="fa fa-home fa-fw"></i>首页</a>

  </li>
        <li class="menu-item menu-item-archives">

    <a href="/archives/" rel="section"><i class="fa fa-archive fa-fw"></i>归档</a>

  </li>
  </ul>
</nav>




</div>
    </header>

    
  <div class="back-to-top">
    <i class="fa fa-arrow-up"></i>
    <span>0%</span>
  </div>


    <main class="main">
      <div class="main-inner">
        <div class="content-wrap">
          

          <div class="content post posts-expand">
            

    
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="http://vchao.top/2017/05/12/%E5%AE%89%E5%8D%93%E5%A4%87%E5%BF%98%EF%BC%9A%E8%B7%B3%E8%BD%AC%E7%B3%BB%E7%BB%9F%E9%A1%B5%E9%9D%A2%E4%BB%A5%E5%8F%8A%E5%B8%B8%E8%A7%81APP%E7%9B%B8%E5%BA%94%E9%A1%B5%E9%9D%A2/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.gif">
      <meta itemprop="name" content="vchao">
      <meta itemprop="description" content="怀揣好奇，梦想改变世界的菜鸟极客">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="乘风破浪">
    </span>
      <header class="post-header">
        <h1 class="post-title" itemprop="name headline">
          安卓备忘：跳转系统页面以及常见APP相应页面
        </h1>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="far fa-calendar"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              <time title="创建时间：2017-05-12 20:03:39" itemprop="dateCreated datePublished" datetime="2017-05-12T20:03:39+08:00">2017-05-12</time>
            </span>
              <span class="post-meta-item">
                <span class="post-meta-item-icon">
                  <i class="far fa-calendar-check"></i>
                </span>
                <span class="post-meta-item-text">更新于</span>
                <time title="修改时间：2021-08-25 22:37:20" itemprop="dateModified" datetime="2021-08-25T22:37:20+08:00">2021-08-25</time>
              </span>
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="far fa-folder"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/Android/" itemprop="url" rel="index"><span itemprop="name">Android</span></a>
                </span>
            </span>

          

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
        <p>﻿&gt;今天需要写一个跳转到系统拨号页面的功能，其实简单的很，就一句话的事儿。不过念在系统页面众多，于是乎，在此做一个总结，万一以后忘记了，也方便查阅。</p>
<h1 id="系统页面"><a href="#系统页面" class="headerlink" title="系统页面"></a>系统页面</h1><h2 id="跳转浏览器浏览网页"><a href="#跳转浏览器浏览网页" class="headerlink" title="跳转浏览器浏览网页"></a>跳转浏览器浏览网页</h2><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">Uri uri = Uri.parse(&quot;http://www.google.com&quot;);   </span><br><span class="line">Intent intent   = new Intent(Intent.ACTION_VIEW,uri);   </span><br><span class="line">startActivity(intent);</span><br></pre></td></tr></table></figure>


<h2 id="拨打电话"><a href="#拨打电话" class="headerlink" title="拨打电话"></a>拨打电话</h2><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line"></span><br><span class="line">//第一种方法</span><br><span class="line">Uri uri = Uri.parse(&quot;tel:xxxxxx&quot;);   </span><br><span class="line">Intent it = new Intent(Intent.ACTION_DIAL, uri);     </span><br><span class="line">startActivity(it);  </span><br><span class="line">//第二种方法</span><br><span class="line">Uri uri = Uri.parse(&quot;tel:&quot;+number);    </span><br><span class="line">Intent intent = new Intent(Intent.ACTION_CALL,uri);    </span><br><span class="line">startActivity(intent);  </span><br></pre></td></tr></table></figure>

<h2 id="调用发短信的程序"><a href="#调用发短信的程序" class="headerlink" title="调用发短信的程序"></a>调用发短信的程序</h2><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br></pre></td><td class="code"><pre><span class="line">Intent it = new Intent(Intent.ACTION_VIEW);     </span><br><span class="line">it.putExtra(&quot;sms_body&quot;, &quot;The SMS text&quot;);     </span><br><span class="line">it.setType(&quot;vnd.android-dir/mms-sms&quot;);     </span><br><span class="line">startActivity(it);</span><br><span class="line">和</span><br><span class="line">uri = Uri.parse(&quot;smsto:&quot;+要发送短信的对方的number);    </span><br><span class="line">intent = new Intent(Intent.ACTION_SENDTO,uri);    </span><br><span class="line">startActivity(intent);   </span><br><span class="line">和</span><br><span class="line">mIntent = new Intent(Intent.ACTION_VIEW);    </span><br><span class="line">mIntent.putExtra(&quot;address&quot;, c.getString(c.getColumnIndex(column)));    </span><br><span class="line">mIntent.setType(&quot;vnd.android-dir/mms-sms&quot;);    </span><br><span class="line">startActivity(mIntent);   </span><br></pre></td></tr></table></figure>

<h2 id="发送短信"><a href="#发送短信" class="headerlink" title="发送短信"></a>发送短信</h2><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br></pre></td><td class="code"><pre><span class="line">Uri uri = Uri.parse(&quot;smsto:0800000123&quot;);     </span><br><span class="line">Intent it = new Intent(Intent.ACTION_SENDTO, uri);     </span><br><span class="line">it.putExtra(&quot;sms_body&quot;, &quot;The SMS text&quot;);     </span><br><span class="line">startActivity(it);   </span><br><span class="line">String body=&quot;this is sms demo&quot;;   </span><br><span class="line">Intent mmsintent = new Intent(Intent.ACTION_SENDTO, Uri.fromParts(&quot;smsto&quot;, number, null));   </span><br><span class="line">mmsintent.putExtra(Messaging.KEY_ACTION_SENDTO_MESSAGE_BODY, body);   </span><br><span class="line">mmsintent.putExtra(Messaging.KEY_ACTION_SENDTO_COMPOSE_MODE, true);   </span><br><span class="line">mmsintent.putExtra(Messaging.KEY_ACTION_SENDTO_EXIT_ON_SENT, true);   </span><br><span class="line">startActivity(mmsintent);</span><br></pre></td></tr></table></figure>

<h2 id="播放多媒体"><a href="#播放多媒体" class="headerlink" title="播放多媒体"></a>播放多媒体</h2><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line">Intent it = new Intent(Intent.ACTION_VIEW);   </span><br><span class="line">Uri uri = Uri.parse(&quot;file:///sdcard/song.mp3&quot;);   </span><br><span class="line">it.setDataAndType(uri, &quot;audio/mp3&quot;);   </span><br><span class="line">startActivity(it);   </span><br><span class="line">Uri uri = Uri.withAppendedPath(MediaStore.Audio.Media.INTERNAL_CONTENT_URI, &quot;1&quot;);     </span><br><span class="line">Intent it = new Intent(Intent.ACTION_VIEW, uri);     </span><br><span class="line">startActivity(it);   </span><br></pre></td></tr></table></figure>

<h2 id="uninstall-apk"><a href="#uninstall-apk" class="headerlink" title="uninstall apk"></a>uninstall apk</h2><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">Uri uri = Uri.fromParts(&quot;package&quot;, strPackageName, null);     </span><br><span class="line">Intent it = new Intent(Intent.ACTION_DELETE, uri);     </span><br><span class="line">startActivity(it);  </span><br></pre></td></tr></table></figure>

<h2 id="install-apk"><a href="#install-apk" class="headerlink" title="install apk"></a>install apk</h2><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">Uri installUri = Uri.fromParts(&quot;package&quot;, &quot;xxx&quot;, null);   </span><br><span class="line">returnIt = new Intent(Intent.ACTION_PACKAGE_ADDED, installUri);  </span><br></pre></td></tr></table></figure>

<h2 id="打开照相机"><a href="#打开照相机" class="headerlink" title="打开照相机"></a>打开照相机</h2><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br></pre></td><td class="code"><pre><span class="line">&lt;1&gt;Intent i = new Intent(Intent.ACTION_CAMERA_BUTTON, null);   </span><br><span class="line">          this.sendBroadcast(i);    </span><br><span class="line">&lt;2&gt;long dateTaken = System.currentTimeMillis();   </span><br><span class="line">         String name = createName(dateTaken) + &quot;.jpg&quot;;   </span><br><span class="line">         fileName = folder + name;   </span><br><span class="line">         ContentValues values = new ContentValues();   </span><br><span class="line">         values.put(Images.Media.TITLE, fileName);   </span><br><span class="line">         values.put(&quot;_data&quot;, fileName);   </span><br><span class="line">         values.put(Images.Media.PICASA_ID, fileName);   </span><br><span class="line">         values.put(Images.Media.DISPLAY_NAME, fileName);   </span><br><span class="line">         values.put(Images.Media.DESCRIPTION, fileName);   </span><br><span class="line">         values.put(Images.ImageColumns.BUCKET_DISPLAY_NAME, fileName);   </span><br><span class="line">         Uri photoUri = getContentResolver().insert(   </span><br><span class="line">         MediaStore.Images.Media.EXTERNAL_CONTENT_URI, values);   </span><br><span class="line"> </span><br><span class="line">         Intent inttPhoto = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);   </span><br><span class="line">         inttPhoto.putExtra(MediaStore.EXTRA_OUTPUT, photoUri);   </span><br><span class="line">         startActivityForResult(inttPhoto, 10);</span><br></pre></td></tr></table></figure>

<p>##从gallery选取图片</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">Intent i = new Intent();   </span><br><span class="line">   i.setType(&quot;image/*&quot;);   </span><br><span class="line">   i.setAction(Intent.ACTION_GET_CONTENT);   </span><br><span class="line">   startActivityForResult(i, 11);  </span><br></pre></td></tr></table></figure>


<p>##打开录音机</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">Intent mi = new Intent(Media.RECORD_SOUND_ACTION);   </span><br><span class="line">startActivity(mi);</span><br></pre></td></tr></table></figure>

<p>##显示应用详细列表</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line">Uri uri = Uri.parse(&quot;market://details?id=app_id&quot;);          </span><br><span class="line">Intent it = new Intent(Intent.ACTION_VIEW, uri);          </span><br><span class="line">startActivity(it);          </span><br><span class="line"></span><br><span class="line"></span><br><span class="line">//where app_id is the application ID, find the ID           </span><br><span class="line">//by clicking on your application on Market home           </span><br><span class="line">//page, and notice the ID from the address bar</span><br></pre></td></tr></table></figure>
<p>刚才找app id未果，结果发现用package name也可以 Uri uri = Uri.parse(“market://details?id=<packagename>“);<br>这个简单多了 </p>
<h2 id="寻找应用"><a href="#寻找应用" class="headerlink" title="寻找应用"></a>寻找应用</h2><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">Uri uri = Uri.parse(&quot;market://search?q=pname:pkg_name&quot;);          </span><br><span class="line">Intent it = new Intent(Intent.ACTION_VIEW, uri);          </span><br><span class="line">startActivity(it);   </span><br><span class="line">//where pkg_name is the full package path for an application</span><br></pre></td></tr></table></figure>

<p>##打开联系人列表</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line">Intent i = new Intent();   </span><br><span class="line">    i.setAction(Intent.ACTION_GET_CONTENT);   </span><br><span class="line">    i.setType(&quot;vnd.android.cursor.item/phone&quot;);   </span><br><span class="line">    startActivityForResult(i, REQUEST_TEXT);</span><br><span class="line">    Uri uri = Uri.parse(&quot;content://contacts/people&quot;);   </span><br><span class="line">    Intent it = new Intent(Intent.ACTION_PICK, uri);   </span><br><span class="line">    startActivityForResult(it, REQUEST_TEXT);</span><br></pre></td></tr></table></figure>


<p>##打开另一程序</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">Intent i = new Intent();   </span><br><span class="line">ComponentName cn = new ComponentName(&quot;com.yellowbook.android2&quot;,   &quot;com.yellowbook.android2.AndroidSearch&quot;);   </span><br><span class="line">i.setComponent(cn);    </span><br><span class="line">i.setAction(&quot;android.intent.action.MAIN&quot;);   </span><br><span class="line">startActivityForResult(i, RESULT_OK);  </span><br></pre></td></tr></table></figure>

<h2 id="添加到短信收件箱"><a href="#添加到短信收件箱" class="headerlink" title="添加到短信收件箱"></a>添加到短信收件箱</h2><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">ContentValues cv = new ContentValues();      </span><br><span class="line">cv.put(&quot;type&quot;, &quot;1&quot;);   </span><br><span class="line">cv.put(&quot;address&quot;,&quot;短信地址&quot;);  </span><br><span class="line">cv.put(&quot;body&quot;, &quot;短信内容&quot;);   </span><br><span class="line">getContentResolver().insert(Uri.parse(&quot;content://sms/inbox&quot;), cv);</span><br></pre></td></tr></table></figure>

<p>##从sim卡或者联系人中查询</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br></pre></td><td class="code"><pre><span class="line">Cursor cursor;  </span><br><span class="line">Uri uri;  </span><br><span class="line">if (type == 1) &#123;  </span><br><span class="line">Intent intent = new Intent();  </span><br><span class="line">intent.setData(Uri.parse(&quot;content://icc/adn&quot;));  </span><br><span class="line">uri = intent.getData();  </span><br><span class="line">&#125; else  </span><br><span class="line">uri = People.CONTENT_URI;  </span><br><span class="line">cursor = activity.getContentResolver().query(uri, null, null, null, null);  </span><br><span class="line">while (cursor.moveToNext()) &#123;  </span><br><span class="line">int peopleId = cursor.getColumnIndex(People._ID);</span><br><span class="line">int nameId = cursor.getColumnIndex(People.NAME); </span><br><span class="line">int phoneId = cursor.getColumnIndex(People.NUMBER);&#125;</span><br><span class="line">查看某个联系人，当然这里是ACTION_VIEW，如果为选择并返回action改为ACTION_PICK，当然处理intent时返回需要用到 startActivityforResult </span><br><span class="line">Uri personUri = ContentUris.withAppendedId(People.CONTENT_URI, ID);//最后的ID参数为联系人Provider中的数据库BaseID，即哪一行 </span><br><span class="line">Intent intent = new Intent(); intent.setAction(Intent.ACTION_VIEW); intent.setData(personUri); startActivity(intent); </span><br></pre></td></tr></table></figure>

<p>##删除</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">uri = ContentUris.withAppendedId(People.CONTENT_URI, 联系人id);  </span><br><span class="line">int count = activity.getContentResolver().delete(uri, null, null</span><br></pre></td></tr></table></figure>

<h2 id="添加到联系人："><a href="#添加到联系人：" class="headerlink" title="添加到联系人："></a>添加到联系人：</h2><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br></pre></td><td class="code"><pre><span class="line">ContentValues cv = new ContentValues();  </span><br><span class="line">ArrayList&lt;ContentProviderOperation&gt; operationList = new ArrayList&lt;ContentProviderOperation&gt;();  </span><br><span class="line">ContentProviderOperation.Builder builder = ContentProviderOperation.newInsert(RawContacts.CONTENT_URI);  </span><br><span class="line">builder.withValues(cv);  </span><br><span class="line">operationList.add(builder.build());  </span><br><span class="line">builder = ContentProviderOperation.newInsert(Data.CONTENT_URI);  </span><br><span class="line">builder.withValueBackReference(StructuredName.RAW_CONTACT_ID, 0);  </span><br><span class="line">builder.withValue(Data.MIMETYPE, StructuredName.CONTENT_ITEM_TYPE);  </span><br><span class="line">builder.withValue(StructuredName.DISPLAY_NAME, &quot;自定义联系人名&quot;);  </span><br><span class="line">operationList.add(builder.build());  </span><br><span class="line">builder = ContentProviderOperation.newInsert(Data.CONTENT_URI);  </span><br><span class="line">builder.withValueBackReference(Phone.RAW_CONTACT_ID, 0);  </span><br><span class="line">builder.withValue(Data.MIMETYPE, Phone.CONTENT_ITEM_TYPE);  </span><br><span class="line">builder.withValue(Phone.NUMBER, &quot;联系人的phonenumber&quot;);  </span><br><span class="line">builder.withValue(Data.IS_PRIMARY, 1);  </span><br><span class="line">operationList.add(builder.build());  </span><br><span class="line">try &#123;  </span><br><span class="line">          getContentResolver().applyBatch(ContactsContract.AUTHORITY, operationList);  </span><br><span class="line">       &#125; catch (RemoteException e) &#123;  </span><br><span class="line">           e.printStackTrace();  </span><br><span class="line">       &#125; catch (OperationApplicationException e) &#123;  </span><br><span class="line">         e.printStackTrace();  </span><br><span class="line">     &#125;  </span><br></pre></td></tr></table></figure>

<p>##选择一个图片</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">Intent intent = new Intent(Intent.ACTION_GET_CONTENT);   </span><br><span class="line">intent.addCategory(Intent.CATEGORY_OPENABLE);  </span><br><span class="line">intent.setType(&quot;image/*&quot;);  </span><br><span class="line">startActivityForResult(intent, 0);   </span><br></pre></td></tr></table></figure>

<h2 id="调用Android设备的照相机，并设置拍照后存放位置"><a href="#调用Android设备的照相机，并设置拍照后存放位置" class="headerlink" title="调用Android设备的照相机，并设置拍照后存放位置"></a>调用Android设备的照相机，并设置拍照后存放位置</h2><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);  </span><br><span class="line">intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(new File(Environment .getExternalStorageDirectory().getAbsolutePath()+&quot;/cwj&quot;, android123 + &quot;.jpg&quot;))); //存放位置为sdcard卡上cwj文件夹，文件名为android123.jpg格式  </span><br><span class="line">startActivityForResult(intent, 0);  </span><br></pre></td></tr></table></figure>

<h2 id="在market上搜索指定package-name，"><a href="#在market上搜索指定package-name，" class="headerlink" title="在market上搜索指定package name，"></a>在market上搜索指定package name，</h2><p>比如搜索com.android123.cwj的写法如下</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">Uri uri = Uri.parse(&quot;market://search?q=pname:com.android123.cwj&quot;);   </span><br><span class="line">Intent intent = new Intent(Intent.ACTION_VIEW, uri); startActivity(intent);</span><br></pre></td></tr></table></figure>


<p>##获取文件信息，并使用相对应软件打开</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br></pre></td><td class="code"><pre><span class="line">private void openFile(File f)    </span><br><span class="line">&#123;    </span><br><span class="line">   Intent intent = new Intent();    </span><br><span class="line">   intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);    </span><br><span class="line">   intent.setAction(android.content.Intent.ACTION_VIEW);    </span><br><span class="line">   String type = getMIMEType(f);    </span><br><span class="line">   intent.setDataAndType(Uri.fromFile(f), type);    </span><br><span class="line">   startActivity(intent);    </span><br><span class="line">&#125;    </span><br><span class="line">private String getMIMEType(File f)&#123;    </span><br><span class="line">   String end = f  .getName() .substring(f.getName().lastIndexOf(&quot;.&quot;) + 1,f.getName().length()).toLowerCase();    </span><br><span class="line">  String type = &quot;&quot;;    </span><br><span class="line">  if (end.equals(&quot;mp3&quot;) || end.equals(&quot;aac&quot;) || end.equals(&quot;aac&quot;)|| end.equals(&quot;amr&quot;) || end.equals(&quot;mpeg&quot;)|| end.equals(&quot;mp4&quot;))    </span><br><span class="line">  &#123;    </span><br><span class="line">     type = &quot;audio&quot;;    </span><br><span class="line">  &#125;</span><br><span class="line">  else if (end.equals(&quot;jpg&quot;) || end.equals(&quot;gif&quot;)|| end.equals(&quot;png&quot;) || end.equals(&quot;jpeg&quot;))    </span><br><span class="line">  &#123; </span><br><span class="line">     type = &quot;image&quot;;    </span><br><span class="line">   &#125;</span><br><span class="line">  else    </span><br><span class="line">  &#123;    </span><br><span class="line">     type = &quot;*&quot;;    </span><br><span class="line">  &#125;    </span><br><span class="line">     type += &quot;/*&quot;;     </span><br><span class="line">     return type;    </span><br><span class="line">&#125; </span><br></pre></td></tr></table></figure>
<h1 id="三方页面"><a href="#三方页面" class="headerlink" title="三方页面"></a>三方页面</h1><p>三方应用在跳转前应该首先进行跳转之前的检查。检测该APP是否已经安装。如果安装再进行跳转，否则可能会出现异常而崩溃。</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br></pre></td><td class="code"><pre><span class="line">//检查某APP是否安装</span><br><span class="line">    public static boolean isAvilible(Context context, String packageName)&#123;   </span><br><span class="line">        //获取packagemanager   </span><br><span class="line">        final PackageManager packageManager = context.getPackageManager();  </span><br><span class="line">      //获取所有已安装程序的包信息   </span><br><span class="line">        List&lt;PackageInfo&gt; packageInfos = packageManager.getInstalledPackages(0);  </span><br><span class="line">      //用于存储所有已安装程序的包名   </span><br><span class="line">        List&lt;String&gt; packageNames = new ArrayList&lt;String&gt;();  </span><br><span class="line">        //从pinfo中将包名字逐一取出，压入pName list中   </span><br><span class="line">        if(packageInfos != null)&#123;   </span><br><span class="line">            for(int i = 0; i &lt; packageInfos.size(); i++)&#123;   </span><br><span class="line">                String packName = packageInfos.get(i).packageName;   </span><br><span class="line">                packageNames.add(packName);   </span><br><span class="line">            &#125;   </span><br><span class="line">        &#125;   </span><br><span class="line">      //判断packageNames中是否有目标程序的包名，有TRUE，没有FALSE   </span><br><span class="line">        return packageNames.contains(packageName);  </span><br><span class="line">  &#125;  </span><br></pre></td></tr></table></figure>

<h2 id="跳转高德地图"><a href="#跳转高德地图" class="headerlink" title="跳转高德地图"></a>跳转高德地图</h2><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">Intent intent = Intent.getIntent(&quot;androidamap://viewMap?sourceApplication=地址&amp;poiname=XX大厦&amp;lat=39.045967&amp;lon=118.93526&amp;dev=0&quot;);  </span><br><span class="line">startActivity(intent);  </span><br></pre></td></tr></table></figure>

<h2 id="跳转添加QQ好友页面"><a href="#跳转添加QQ好友页面" class="headerlink" title="跳转添加QQ好友页面"></a>跳转添加QQ好友页面</h2><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">String url = &quot;mqqwpa://im/chat?chat_type=wpa&amp;uin=2318723605&quot;;//uin是发送过去的qq号码</span><br><span class="line">startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url)));</span><br></pre></td></tr></table></figure>




    </div>

    
    
    

      <footer class="post-footer">
          <div class="post-tags">
              <a href="/tags/Android/" rel="tag"># Android</a>
              <a href="/tags/Android-Studio/" rel="tag"># Android Studio</a>
          </div>

        


        
    <div class="post-nav">
      <div class="post-nav-item">
    <a href="/2017/05/12/%E5%AE%89%E5%8D%93%EF%BC%9AFragment%E7%9A%84%E6%87%92%E5%8A%A0%E8%BD%BD/" rel="prev" title="安卓：Fragment的懒加载">
      <i class="fa fa-chevron-left"></i> 安卓：Fragment的懒加载
    </a></div>
      <div class="post-nav-item">
    <a href="/2017/05/12/%E5%8A%A8%E6%80%81%E6%9B%B4%E6%8D%A2%E5%BA%94%E7%94%A8%E5%9B%BE%E6%A0%87%EF%BC%9Aactivity-alias%E8%AF%A6%E8%A7%A3%E5%8F%8A%E5%BA%94%E7%94%A8/" rel="next" title="动态更换应用图标：activity-alias详解及应用">
      动态更换应用图标：activity-alias详解及应用 <i class="fa fa-chevron-right"></i>
    </a></div>
    </div>
      </footer>
    
  </article>
  
  
  



          </div>
          

<script>
  window.addEventListener('tabs:register', () => {
    let { activeClass } = CONFIG.comments;
    if (CONFIG.comments.storage) {
      activeClass = localStorage.getItem('comments_active') || activeClass;
    }
    if (activeClass) {
      let activeTab = document.querySelector(`a[href="#comment-${activeClass}"]`);
      if (activeTab) {
        activeTab.click();
      }
    }
  });
  if (CONFIG.comments.storage) {
    window.addEventListener('tabs:click', event => {
      if (!event.target.matches('.tabs-comment .tab-content .tab-pane')) return;
      let commentClass = event.target.classList[1];
      localStorage.setItem('comments_active', commentClass);
    });
  }
</script>

        </div>
          
  
  <div class="toggle sidebar-toggle">
    <span class="toggle-line toggle-line-first"></span>
    <span class="toggle-line toggle-line-middle"></span>
    <span class="toggle-line toggle-line-last"></span>
  </div>

  <aside class="sidebar">
    <div class="sidebar-inner">

      <ul class="sidebar-nav motion-element">
        <li class="sidebar-nav-toc">
          文章目录
        </li>
        <li class="sidebar-nav-overview">
          站点概览
        </li>
      </ul>

      <!--noindex-->
      <div class="post-toc-wrap sidebar-panel">
          <div class="post-toc motion-element"><ol class="nav"><li class="nav-item nav-level-1"><a class="nav-link" href="#%E7%B3%BB%E7%BB%9F%E9%A1%B5%E9%9D%A2"><span class="nav-number">1.</span> <span class="nav-text">系统页面</span></a><ol class="nav-child"><li class="nav-item nav-level-2"><a class="nav-link" href="#%E8%B7%B3%E8%BD%AC%E6%B5%8F%E8%A7%88%E5%99%A8%E6%B5%8F%E8%A7%88%E7%BD%91%E9%A1%B5"><span class="nav-number">1.1.</span> <span class="nav-text">跳转浏览器浏览网页</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E6%8B%A8%E6%89%93%E7%94%B5%E8%AF%9D"><span class="nav-number">1.2.</span> <span class="nav-text">拨打电话</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E8%B0%83%E7%94%A8%E5%8F%91%E7%9F%AD%E4%BF%A1%E7%9A%84%E7%A8%8B%E5%BA%8F"><span class="nav-number">1.3.</span> <span class="nav-text">调用发短信的程序</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E5%8F%91%E9%80%81%E7%9F%AD%E4%BF%A1"><span class="nav-number">1.4.</span> <span class="nav-text">发送短信</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E6%92%AD%E6%94%BE%E5%A4%9A%E5%AA%92%E4%BD%93"><span class="nav-number">1.5.</span> <span class="nav-text">播放多媒体</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#uninstall-apk"><span class="nav-number">1.6.</span> <span class="nav-text">uninstall apk</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#install-apk"><span class="nav-number">1.7.</span> <span class="nav-text">install apk</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E6%89%93%E5%BC%80%E7%85%A7%E7%9B%B8%E6%9C%BA"><span class="nav-number">1.8.</span> <span class="nav-text">打开照相机</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E5%AF%BB%E6%89%BE%E5%BA%94%E7%94%A8"><span class="nav-number">1.9.</span> <span class="nav-text">寻找应用</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E6%B7%BB%E5%8A%A0%E5%88%B0%E7%9F%AD%E4%BF%A1%E6%94%B6%E4%BB%B6%E7%AE%B1"><span class="nav-number">1.10.</span> <span class="nav-text">添加到短信收件箱</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E6%B7%BB%E5%8A%A0%E5%88%B0%E8%81%94%E7%B3%BB%E4%BA%BA%EF%BC%9A"><span class="nav-number">1.11.</span> <span class="nav-text">添加到联系人：</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E8%B0%83%E7%94%A8Android%E8%AE%BE%E5%A4%87%E7%9A%84%E7%85%A7%E7%9B%B8%E6%9C%BA%EF%BC%8C%E5%B9%B6%E8%AE%BE%E7%BD%AE%E6%8B%8D%E7%85%A7%E5%90%8E%E5%AD%98%E6%94%BE%E4%BD%8D%E7%BD%AE"><span class="nav-number">1.12.</span> <span class="nav-text">调用Android设备的照相机，并设置拍照后存放位置</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E5%9C%A8market%E4%B8%8A%E6%90%9C%E7%B4%A2%E6%8C%87%E5%AE%9Apackage-name%EF%BC%8C"><span class="nav-number">1.13.</span> <span class="nav-text">在market上搜索指定package name，</span></a></li></ol></li><li class="nav-item nav-level-1"><a class="nav-link" href="#%E4%B8%89%E6%96%B9%E9%A1%B5%E9%9D%A2"><span class="nav-number">2.</span> <span class="nav-text">三方页面</span></a><ol class="nav-child"><li class="nav-item nav-level-2"><a class="nav-link" href="#%E8%B7%B3%E8%BD%AC%E9%AB%98%E5%BE%B7%E5%9C%B0%E5%9B%BE"><span class="nav-number">2.1.</span> <span class="nav-text">跳转高德地图</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E8%B7%B3%E8%BD%AC%E6%B7%BB%E5%8A%A0QQ%E5%A5%BD%E5%8F%8B%E9%A1%B5%E9%9D%A2"><span class="nav-number">2.2.</span> <span class="nav-text">跳转添加QQ好友页面</span></a></li></ol></li></ol></div>
      </div>
      <!--/noindex-->

      <div class="site-overview-wrap sidebar-panel">
        <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
  <p class="site-author-name" itemprop="name">vchao</p>
  <div class="site-description" itemprop="description">怀揣好奇，梦想改变世界的菜鸟极客</div>
</div>
<div class="site-state-wrap motion-element">
  <nav class="site-state">
      <div class="site-state-item site-state-posts">
          <a href="/archives/">
        
          <span class="site-state-item-count">46</span>
          <span class="site-state-item-name">日志</span>
        </a>
      </div>
      <div class="site-state-item site-state-categories">
        <span class="site-state-item-count">4</span>
        <span class="site-state-item-name">分类</span>
      </div>
      <div class="site-state-item site-state-tags">
        <span class="site-state-item-count">27</span>
        <span class="site-state-item-name">标签</span>
      </div>
  </nav>
</div>



      </div>

    </div>
  </aside>
  <div id="sidebar-dimmer"></div>


      </div>
    </main>

    <footer class="footer">
      <div class="footer-inner">
        

        
  <div class="beian"><a href="https://beian.miit.gov.cn/" rel="noopener" target="_blank">冀ICP备 17022751号-1 </a>
      <img src="https://beian.miit.gov.cn" style="display: inline-block;">
  </div>

<div class="copyright">
  
  &copy; 
  <span itemprop="copyrightYear">2021</span>
  <span class="with-love">
    <i class="fa fa-heart"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">vchao</span>
</div>
  <div class="powered-by">由 <a href="https://hexo.io/" class="theme-link" rel="noopener" target="_blank">Hexo</a> & <a href="https://muse.theme-next.org/" class="theme-link" rel="noopener" target="_blank">NexT.Muse</a> 强力驱动
  </div>

        








      </div>
    </footer>
  </div>

  
  <script src="/lib/anime.min.js"></script>
  <script src="/lib/velocity/velocity.min.js"></script>
  <script src="/lib/velocity/velocity.ui.min.js"></script>

<script src="/js/utils.js"></script>

<script src="/js/motion.js"></script>


<script src="/js/schemes/muse.js"></script>


<script src="/js/next-boot.js"></script>




  















  

  

</body>
</html>
